const {
  $util,
} = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    rankList: [],
    rankidx: 1,
    imgUrl: $util.getImgUrl(),
  },
  onShow() {
    let wxData = wx.getStorageSync('qyUserInfo') || {};
    this.setData(wxData);
    this.setData({
      isSaaS: wx.getStorageSync('isSaaS'),
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id,
      title: decodeURIComponent(options.title),
    });
    this.getSortList();
  },
  getSortList() {
    $util.request({
      url: 'entry/wxapp/edu.exam.ranking',
      data: {
        testpaperid: this.data.id,
        type: this.data.rankidx,
      },
      success: (res) => {
        this.setData({
          rankList: res.list,
          total_num: res.total_num,
          current_idx: res.current_idx,
          isLoad: true,
        });
      },
    });
  },
  bindchange(e) {
    this.setData({
      rankList: [],
      rankidx: e.currentTarget.dataset.idx,
      isLoad: false,
    });
    this.getSortList();
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
});